package edu.towson.cosc.cosc490.eangel1.lab3;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ToDoListActivity extends Activity implements OnClickListener {
	
	Button m_addButton;
	EditText m_editText;
	LinearLayout m_itemListView;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_to_do_list);
        initLayout();
        m_addButton.setOnClickListener(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_to_do_list, menu);
        return true;
    }
    
    public void initLayout(){
    	m_addButton = (Button) this.findViewById(R.id.button1);
    	m_editText = (EditText) this.findViewById(R.id.editText1);
    	m_itemListView = (LinearLayout) this.findViewById(R.id.toDoListView);
    }

	public void onClick(View v) {
		// TODO Auto-generated method stub
        String text = m_editText.getText().toString();
        ToDoitem newItem = new ToDoitem(text);
        TextView newItemTextView = new TextView(this);
        m_itemListView.addView(newItemTextView);
        m_editText.setText(null);
	}
}
